<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">系统设置</a>
        <a href="#">权限列表</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div style="height: 50px"></div>
<xblock>
    <button class="layui-btn" id="edit"><i class="layui-icon layui-icon-edit"></i>修改权限</button>
</xblock>
<form class="layui-form" onsubmit="return false" id="rule">
    <div class="layui-form-item">
        <div class="layui-input-block">
            {foreach $ruleList as $value}
                <input type="radio" name="scope" value="{$value.scope}" title="{$value.scope_name}">
            {/foreach}
        </div>
    </div>
</form>
<script>
    //初始化表单
    layui.use('form', function(){
        form = layui.form;
    });
</script>
</body>
<script>
    $("#edit").click(function(){
        if(!$("input[name=scope]:checked").val()){
            layer.msg('请选择需要修改的权限',{icon:5,time:2000});
            return;
        }
        layer.prompt({
            formType: 2,
            title: '权限修改',
            area: ['200px', '100px']
        }, function(value, index, elem){
            $.ajax({
                url:"{:url('/rule/update')}",
                type:"post",
                data:{
                    scope:$("input[name=scope]:checked").val(),
                    scope_name:value
                },
                dataType:"json",
                success:function(res){
                    if(res.code){
                        layer.msg(res.msg,{icon:1,time:2000},function(){
                            layer.close(index);
                            window.location.reload();
                        });
                    }else{
                        layer.msg(res.msg,{icon:1,time:2000});
                        return;
                    }
                }
            });
        });
    });
</script>
</html>